<template>

<h1>理财项目信息展示</h1>

<FinanAll v-slot="info">
    <input type="button" value="修改" @click="jump(info.id)">
    <input type="button" value="删除" @click="DelData(info.id)">
</FinanAll>
    


</template>

<script setup lang="ts">
import FinanAll from '../Finan/FinanAll.vue' 

import axios from "axios"
import { useRouter } from "vue-router"

const router = useRouter();


//删除方法
const DelData = (Id:string)=>{
    if(confirm("确定要删除吗?")){
        axios({
            method:"get",
            url:"http://localhost:63517/api/Finan/DelData",
            params:{
                Id:Id
            }
        })
        .then(res=>{
            if(res.data>0){
                alert('删除成功!');
                router.push('/ShowInvestInfo')
            }
            else if(res.data==-1){
                alert('有人理财,无法删除!');
                return;
            }
            else{
                alert('删除失败!');
                return;
            }
        })
        .catch(err=>{
            console.log(err)
        })
    }
}

//跳转修改页面
const jump = (Id:string)=>{
    router.push({
        name:'EditFinan',
        params:{
            Id:Id
        }
    })
}


</script>